package org.dashboard.utils;

import java.sql.SQLException;
import java.util.Properties;
import javax.sql.DataSource;

import org.apache.commons.dbutils.QueryRunner;

public class DbUtilsHelper {

    private DataSource dataSource = null;
    private QueryRunner queryRunner = null;

    public DbUtilsHelper(Properties env) {
        try {
            this.dataSource = DbPoolConnection.getInstance().getDataSource(env);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        if (this.dataSource != null) {
            this.queryRunner = new QueryRunner(this.dataSource);
        }
    }

    public DbUtilsHelper(DataSource dataSource) {
        this.dataSource = dataSource;
        this.queryRunner = new QueryRunner(this.dataSource);
    }

    public QueryRunner getRunner() {
        return this.queryRunner;
    }

}